package com.app.teaware.bean;


import android.text.TextUtils;

import com.alibaba.fastjson.annotation.JSONField;
import com.app.teaware.ware.AllCheckListActivity;

import java.util.ArrayList;

public class GoodsWorksListBean extends BaseListBean {



    private ArrayList<GoodsWorks> list = new ArrayList<GoodsWorks>();

    public ArrayList<GoodsWorks> getList() {
        return list;
    }

    public void setList(ArrayList<GoodsWorks> list) {
        this.list = list;
    }

    @JSONField(serialize = false)
    public void addListBean(GoodsWorksListBean listbean) {
        if (listbean == null)
            return;
        if (this.getCurrentPage() == INIT_PAGE) {
            setList(listbean.getList());
        } else {
            if (list == null)
                list = new ArrayList<GoodsWorks>();
            list.addAll(listbean.getList());
        }
        setListBeanData(listbean);
    }


    @JSONField(serialize = false)
    public void haveRfid(String rfid, AllCheckListActivity.MyAdapterList adapterList){
        boolean isHave = false;
        for (GoodsWorks data : list){
            if(data.getRfid().equals(rfid)){
                isHave = true;
            }
        }
        if(!isHave){
            GoodsWorks newData = new GoodsWorks();
            newData.setRfid(rfid);
            list.add(newData);
            adapterList.notifyDataSetChanged();
        }
    }

    @JSONField(serialize = false)
    public String getRfidListString(){
        String value = "";
        for (GoodsWorks data : list){
            value += data.getRfid()+",";
        }
        if(TextUtils.isEmpty(value)){
            return value;
        }
        return value.substring(0,value.length()-1);
    }


}
